<template>
    <div id="templateDiv">
        <Spin size="large" fix v-if="Loading"></Spin>
        <Form :label-width="130" inline>
            <Row>
                <i-col span="6">
                    <Form-item label="身份证号码：">
                        <Input v-model="dczb0001" placeholder="请输入户主身份证号码" style="width:200px"
                               @on-change="changeDczb0001"/>
                    </Form-item>
                </i-col>
            </Row>
            <Row class="button_row">
                <span style="float: right;">
                    <Button type="primary" @click="select">查询</Button>
                    <Button type="primary" class="button_item_left" @click="reset">重置</Button>
                </span>
            </Row>
        </Form>
        <Tabs type="card">
            <Tab-pane label="首页打印--页码2" name="homePage">
                <low-home-page v-if="finish" :dcza0011="dcza0011" :ss22001Dto="ss22001Dto" :ss22002Dto="ss22002Dto"
                               :lodopHomePagePrint="lodopHomePagePrint" @finishCertificate="finishCertificate"/>
            </Tab-pane>

            <Tab-pane label="家庭基本信息/家庭成员基本信息页打印--页码3、4" name="familyInformation">
                <low-family-information v-if="finish" :ss22001Dto="ss22001Dto" :ss22002DtoList="ss22002DtoList"
                                        :dcza0011="dcza0011"
                                        :ss22002Dto="ss22002Dto" :lodopLowFamilyInformation="lodopLowFamilyInformation"
                                        @finishCertificate="finishCertificate"/>
            </Tab-pane>
            <Tab-pane label="换证打印" name="updateCertificate">
                <low-update-certificate v-if="finish" :dczb0001="dczb0001" @finishCertificate="finishCertificate"/>
            </Tab-pane>
        </Tabs>
    </div>
</template>

<script>
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import lowHomePage from './modules/lowHomePage'
    import lowFamilyInformation from './modules/lowFamilyInformation'
    import {postAction} from '@/api/request'
    import lowUpdateCertificate from './modules/lowUpdateCertificate'

    export default {
        name: "low",
        mixins: [CommonMixin],
        components: {
            lowHomePage,
            lowFamilyInformation,
            lowUpdateCertificate
        },
        data() {
            return {
                finish: false,
                url: {
                    low: "/api/ac/subsistence/lodopFamilyServiceImpl/low",
                },
                Loading: false,
                ss22001Dto: {},
                ss22002Dto: {},
                ss22002DtoList: [],
                lodopHomePagePrint: {},
                lodopLowFamilyInformation: {},
                dcza0011: "",
                dczb0001: "",
            }
        },
        methods: {
            select() {
                this.finish = false;
                if (this.dczb0001) {
                    this.getLow();
                } else {
                    this.$Message.error("请输入户主身份证号码！")
                }
            },
            getLow() {
                var param = new Object();
                param.dczb0001 = this.dczb0001;
                this.Loading = true;
                postAction(this.url.low, param).then((res) => {
                    if (res.data.errcode != 0) {
                        this.$Message.error(res.data.errmsg);
                    } else {
                        this.ss22001Dto = res.data.data.ss22001Dto;
                        this.ss22002Dto = res.data.data.ss22002Dto;
                        this.ss22002DtoList = res.data.data.ss22002DtoList;
                        this.lodopHomePagePrint = res.data.data.lodopHomePagePrint;
                        this.lodopLowFamilyInformation = res.data.data.lodopLowFamilyInformation;
                        this.dcza0011 = res.data.data.ss22001Dto.dcza0011;
                        this.finish = true;
                    }
                }).finally(() => {
                    this.Loading = false;
                })
            },
            changeDczb0001() {
                this.finish = false;
            },
            reset() {
                this.dczb0001 = "";
                this.finish = false;
            },
            finishCertificate() {
                this.changeDczb0001();
                this.select();
            }
        },
    }
</script>

<style scoped>
    /deep/ .ivu-tabs-tabpane {
        height: calc(100% - 20px);
        overflow-y: auto;
        margin-top: 20px;
    }

    /deep/ .ivu-tabs-card {
        height: calc(100% - 70px);
    }

    /deep/ .ivu-tabs-content {
        height: calc(100% - 45px);
    }

    /deep/ .ivu-form-item-label {
        text-align: center;
    }

    .contentDiv {
        width: 800px;
        height: 100%;
        position: relative;
        margin: 0 auto;
    }
</style>